package com.som.beanconvert.data1.input;

import java.util.HashMap;
import java.util.Map;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.ss.usermodel.Row;

import com.som.bean.data1.input.IpAddressAllInfo;
import com.som.bean.data1.input.NeAreaInfo;
import com.som.beanconvert.ExcelDataParseInputInf;
import com.som.beanconvert.ExcelRowDataParseProcessInf;
import com.som.util.ExcelCellStrGet;

/**
 * 输入数据二：网元和区县对应表(输入文件名为input2.xls),输入列为三列，LOOPBACK地址，设备名称，区县
 * 
 * @author liujun
 * @date 2016年4月8日
 * @verion 0.0.1
 */
public class NeAreaExcelInput extends IpAddressAllInfo implements ExcelDataParseInputInf<NeAreaInfo>, ExcelRowDataParseProcessInf<String, NeAreaInfo>
{

	public NeAreaInfo parseBean(Row excelRow)
	{
		HSSFRow row = (HSSFRow) excelRow;

		NeAreaInfo neare = new NeAreaInfo();

		// LOOPBACK地址
		HSSFCell celllb = row.getCell(0);
		neare.setLoopbackAddress(ExcelCellStrGet.getCellValue(celllb));

		// 设备名称
		HSSFCell cellname = row.getCell(1);
		neare.setName(ExcelCellStrGet.getCellValue(cellname));

		// 区县
		HSSFCell cellarea = row.getCell(2);
		neare.setArea(ExcelCellStrGet.getCellValue(cellarea));

		return neare;
	}

	public Map<String, NeAreaInfo> parseRowDataProcess(NeAreaInfo t)
	{
		if (null != t)
		{
			Map<String, NeAreaInfo> map = new HashMap<String, NeAreaInfo>();

			// 以loopback为键，其他信息为值，进行数据的合并
			map.put(t.getLoopbackAddress(), t);
			
			return map;
		}

		return null;
	}

}
